

Q&A





STATIC DoingIt AS _BYTE 'Flag to indicate a LOOP is being run
SELECT CASE id
CASE IntenseCalculator
CASE QuitBT
SYSTEM
CASE StartBT
IF NOT DoingIt THEN
PrevCaption$ = Caption(StartBT)
Caption(StartBT) = "Cancel"
Caption(PB) = "Locating stars in observable universe... \#"
DoingIt = True
Control(PB).Hidden = False
Control(PB).Value = 0
BeginDraw PictureBox1
CLS
EndDraw PictureBox1
StartTime! = TIMER
DO
Control(PB).Value = Control(PB).Value + 1
BeginDraw PictureBox1
PSET (RND * _WIDTH, RND * _HEIGHT), _RGB32(RND * 255, RND * 255, RND * 255)
EndDraw PictureBox1
__UI_DoEvents 'This is what you'll want to have in your main loop
_LIMIT 30 'simulate a loop that takes a good while...
LOOP UNTIL DoingIt = False OR Control(PB).Value >= Control(PB).Max
Control(PB).Hidden = True
Control(StartBT).Disabled = False
Caption(StartBT) = PrevCaption$
BeginDraw PictureBox1
IF DoingIt = False THEN PRINT "Canceled."
DoingIt = False
PRINT "Seconds since start:"
PRINT TIMER - StartTime!
EndDraw PictureBox1
ELSE
DoingIt = False
END IF
CASE PictureBox1
CASE PB
END SELECT
END SUB



an example for multiple labels:
in MyProgram.FRM file in SUB __UI_LoadForm
DIM IDname AS STRING
...
for i = 1 to 12 step 1
IDname = "Label"
IDname = IDname+Ltrim$(Str$(i))
__UI_NewID = __UI_NewControl(__UI_Type_Label, IDname, 150, 23, 10, 10, 0)
if __UI_NewID = 0 then end else SetCaption __UI_NewID, IDname
Control(__UI_NewID).VAlign = __UI_Middle
next i
and in SUB __UI_AssignIDs
...
for i = 1 to 12 step 1
Label1(i) = __UI_GetID("Label"+Ltrim$(Str$(i)))
next i
and at the end in MyProgram.BAS
.....
DIM SHARED Label1(1 TO 12) AS LONG





__UI_MouseUp: is true if mouse is on the control_ID and releases a Mouse_button
__UI_MouseDown : is true if mouse on the control_ID and presses a Mouse_button
__UI_MouseEnter: is true if mouse is on the control_ID
__UI_MouseLeave: is true if mouse is out of the control_ID


FUNCTION MessageBox& (Message$, Title$, Setup AS LONG)
Not specifying Title$ will have the message box inherit the main form's title/caption.
Setup is a combination (button + icon) of:
Buttons, which can be MsgBox_OkOnly, MsgBox_OkCancel, MsgBox_AbortRetryIgnore, MsgBox_YesNoCancel, MsgBox_YesNo, MsgBox_RetryCancel, MsgBox_CancelTryagainContinue, MsgBox_CancelTryagainContinue.
Icons, which can be MsgBox_Critical, MsgBox_Question, MsgBox_Exclamation, MsgBox_Information
The possible return values are: MsgBox_Ok, MsgBox_Cancel, MsgBox_Abort, MsgBox_Retry, MsgBox_Ignore, MsgBox_Yes, MsgBox_No, MsgBox_Tryagain, MsgBox_Continue.
All combinations of the above work as expected in Windows.
For macOS and Linux, you only get OkOnly and YesNo for buttons.



